<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>QtWebApp: stefanfrings::HttpListener Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">QtWebApp
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classstefanfrings_1_1HttpListener.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#signals">Signals</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classstefanfrings_1_1HttpListener-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">stefanfrings::HttpListener Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Listens for incoming TCP connections and and passes all incoming HTTP requests to your implementation of <a class="el" href="classstefanfrings_1_1HttpRequestHandler.html" title="The request handler generates a response for each HTTP request.">HttpRequestHandler</a>, which processes the request and generates the response (usually a HTML document).  
 <a href="classstefanfrings_1_1HttpListener.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="httplistener_8h_source.html">httplistener.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stefanfrings::HttpListener:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1HttpListener__inherit__graph.png" border="0" usemap="#astefanfrings_1_1HttpListener_inherit__map" alt="Inheritance graph"/></div>
<map name="astefanfrings_1_1HttpListener_inherit__map" id="astefanfrings_1_1HttpListener_inherit__map">
<area shape="rect" title="Listens for incoming TCP connections and and passes all incoming HTTP requests to your implementation..." alt="" coords="5,80,193,107"/>
<area shape="rect" title=" " alt="" coords="52,5,147,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for stefanfrings::HttpListener:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1HttpListener__coll__graph.png" border="0" usemap="#astefanfrings_1_1HttpListener_coll__map" alt="Collaboration graph"/></div>
<map name="astefanfrings_1_1HttpListener_coll__map" id="astefanfrings_1_1HttpListener_coll__map">
<area shape="rect" title="Listens for incoming TCP connections and and passes all incoming HTTP requests to your implementation..." alt="" coords="5,80,193,107"/>
<area shape="rect" title=" " alt="" coords="52,5,147,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="signals"></a>
Signals</h2></td></tr>
<tr class="memitem:a60065df255188a04088d3a7c0b3def44"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1HttpListener.html#a60065df255188a04088d3a7c0b3def44">handleConnection</a> (<a class="el" href="httpconnectionhandler_8h.html#aac9d80ca2f2f3e2c74506d3b207b02d6">tSocketDescriptor</a> socketDescriptor)</td></tr>
<tr class="memdesc:a60065df255188a04088d3a7c0b3def44"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sent to the connection handler to process a new incoming connection.  <a href="classstefanfrings_1_1HttpListener.html#a60065df255188a04088d3a7c0b3def44">More...</a><br /></td></tr>
<tr class="separator:a60065df255188a04088d3a7c0b3def44"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a4f92377bf5d139ff3706a0b41fce1fc1"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1HttpListener.html#a4f92377bf5d139ff3706a0b41fce1fc1">HttpListener</a> (const QSettings *settings, <a class="el" href="classstefanfrings_1_1HttpRequestHandler.html">HttpRequestHandler</a> *requestHandler, QObject *parent=nullptr)</td></tr>
<tr class="memdesc:a4f92377bf5d139ff3706a0b41fce1fc1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor.  <a href="classstefanfrings_1_1HttpListener.html#a4f92377bf5d139ff3706a0b41fce1fc1">More...</a><br /></td></tr>
<tr class="separator:a4f92377bf5d139ff3706a0b41fce1fc1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abf6e9c9d9715a94d922a1d437e02ee6e"><td class="memItemLeft" align="right" valign="top"><a id="abf6e9c9d9715a94d922a1d437e02ee6e"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1HttpListener.html#abf6e9c9d9715a94d922a1d437e02ee6e">~HttpListener</a> ()</td></tr>
<tr class="memdesc:abf6e9c9d9715a94d922a1d437e02ee6e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor. <br /></td></tr>
<tr class="separator:abf6e9c9d9715a94d922a1d437e02ee6e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a39cf1136caf6ba96554ef0a48fbff052"><td class="memItemLeft" align="right" valign="top"><a id="a39cf1136caf6ba96554ef0a48fbff052"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1HttpListener.html#a39cf1136caf6ba96554ef0a48fbff052">listen</a> ()</td></tr>
<tr class="memdesc:a39cf1136caf6ba96554ef0a48fbff052"><td class="mdescLeft">&#160;</td><td class="mdescRight">Restart listeing after <a class="el" href="classstefanfrings_1_1HttpListener.html#a5f5f2463036bc9a17f9fe8eb5c17c7f5" title="Closes the listener, waits until all pending requests are processed, then closes the connection pool.">close()</a>. <br /></td></tr>
<tr class="separator:a39cf1136caf6ba96554ef0a48fbff052"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5f5f2463036bc9a17f9fe8eb5c17c7f5"><td class="memItemLeft" align="right" valign="top"><a id="a5f5f2463036bc9a17f9fe8eb5c17c7f5"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1HttpListener.html#a5f5f2463036bc9a17f9fe8eb5c17c7f5">close</a> ()</td></tr>
<tr class="memdesc:a5f5f2463036bc9a17f9fe8eb5c17c7f5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Closes the listener, waits until all pending requests are processed, then closes the connection pool. <br /></td></tr>
<tr class="separator:a5f5f2463036bc9a17f9fe8eb5c17c7f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a72530470ad6a62487b7b0d3d5c79d7b9"><td class="memItemLeft" align="right" valign="top"><a id="a72530470ad6a62487b7b0d3d5c79d7b9"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1HttpListener.html#a72530470ad6a62487b7b0d3d5c79d7b9">incomingConnection</a> (<a class="el" href="httpconnectionhandler_8h.html#aac9d80ca2f2f3e2c74506d3b207b02d6">tSocketDescriptor</a> socketDescriptor)</td></tr>
<tr class="memdesc:a72530470ad6a62487b7b0d3d5c79d7b9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Serves new incoming connection requests. <br /></td></tr>
<tr class="separator:a72530470ad6a62487b7b0d3d5c79d7b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Listens for incoming TCP connections and and passes all incoming HTTP requests to your implementation of <a class="el" href="classstefanfrings_1_1HttpRequestHandler.html" title="The request handler generates a response for each HTTP request.">HttpRequestHandler</a>, which processes the request and generates the response (usually a HTML document). </p>
<p>Example for the required settings in the config file: <code></p><pre>
;host=192.168.0.100
port=8080
minThreads=1
maxThreads=10
cleanupInterval=1000
readTimeout=60000
;sslKeyFile=ssl/my.key
;sslCertFile=ssl/my.cert
maxRequestSize=16000
maxMultiPartSize=1000000
</pre><p></code> The optional host parameter binds the listener to one network interface. The listener handles all network interfaces if no host is configured. The port number specifies the incoming TCP port that this listener listens to. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="classstefanfrings_1_1HttpConnectionHandlerPool.html" title="Pool of http connection handlers.">HttpConnectionHandlerPool</a> for description of config settings minThreads, maxThreads, cleanupInterval and ssl settings </dd>
<dd>
<a class="el" href="classstefanfrings_1_1HttpConnectionHandler.html" title="Alias for QSslConfiguration if OpenSSL is not supported.">HttpConnectionHandler</a> for description of the readTimeout </dd>
<dd>
<a class="el" href="classstefanfrings_1_1HttpRequest.html" title="This object represents a single HTTP request.">HttpRequest</a> for description of config settings maxRequestSize and maxMultiPartSize </dd></dl>

<p class="definition">Definition at line <a class="el" href="httplistener_8h_source.html#l00044">44</a> of file <a class="el" href="httplistener_8h_source.html">httplistener.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a4f92377bf5d139ff3706a0b41fce1fc1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4f92377bf5d139ff3706a0b41fce1fc1">&#9670;&nbsp;</a></span>HttpListener()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">HttpListener::HttpListener </td>
          <td>(</td>
          <td class="paramtype">const QSettings *&#160;</td>
          <td class="paramname"><em>settings</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classstefanfrings_1_1HttpRequestHandler.html">HttpRequestHandler</a> *&#160;</td>
          <td class="paramname"><em>requestHandler</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">QObject *&#160;</td>
          <td class="paramname"><em>parent</em> = <code>nullptr</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructor. </p>
<p>Creates a connection pool and starts listening on the configured host and port. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">settings</td><td>Configuration settings, usually stored in an INI file. Must not be 0. Settings are read from the current group, so the caller must have called settings-&gt;beginGroup(). Because the group must not change during runtime, it is recommended to provide a separate QSettings instance that is not used by other parts of the program. The <a class="el" href="classstefanfrings_1_1HttpListener.html" title="Listens for incoming TCP connections and and passes all incoming HTTP requests to your implementation...">HttpListener</a> does not take over ownership of the QSettings instance, so the caller should destroy it during shutdown. </td></tr>
    <tr><td class="paramname">requestHandler</td><td>Processes each received HTTP request, usually by dispatching to controller classes. </td></tr>
    <tr><td class="paramname">parent</td><td>Parent object. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section warning"><dt>Warning</dt><dd>Ensure to close or delete the listener before deleting the request handler. </dd></dl>

<p class="definition">Definition at line <a class="el" href="httplistener_8cpp_source.html#l00013">13</a> of file <a class="el" href="httplistener_8cpp_source.html">httplistener.cpp</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a60065df255188a04088d3a7c0b3def44"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a60065df255188a04088d3a7c0b3def44">&#9670;&nbsp;</a></span>handleConnection</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void stefanfrings::HttpListener::handleConnection </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="httpconnectionhandler_8h.html#aac9d80ca2f2f3e2c74506d3b207b02d6">tSocketDescriptor</a>&#160;</td>
          <td class="paramname"><em>socketDescriptor</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">signal</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Sent to the connection handler to process a new incoming connection. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">socketDescriptor</td><td>references the accepted connection. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>httpserver/<a class="el" href="httplistener_8h_source.html">httplistener.h</a></li>
<li>httpserver/<a class="el" href="httplistener_8cpp_source.html">httplistener.cpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>stefanfrings</b></li><li class="navelem"><a class="el" href="classstefanfrings_1_1HttpListener.html">HttpListener</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
